// JavaScript Document
$(function(){

	var arr=['#540405','#FC8ABB','#0E51AA','#EF2243','#EE3E17','#DA142D','#293C9A','#E32B2B','#532AA2'];
	var imgs=document.getElementsByClassName('lun-tu');
	var lis=document.getElementsByClassName('lun-xia');
	var bg=document.getElementById('middle-big');
	var box=document.getElementById('lun-father');
	var num=0;

	function run(){
		num++;
		num= num>= imgs.length ? 0 : num;
		//alert(imgs.length);
		for(var i=0;i<imgs.length;i++){
			imgs[i].style.display="none";
			lis[i].style.background='rgba(0,0,0,0.5)';
		}
		bg.style.background=arr[num];
		imgs[num].style.display='block';
		lis[num].style.background='none';
	}
	timer=setInterval(run,2000);
// 当鼠标移动上去的时候和移走的时候
	box.onmouseover=function(){
		clearInterval(timer);
		$('.ll,.lr').css({display:'block'});
	}

	box.onmouseout=function(){
		timer=setInterval(run,2000);
		$('.ll,.lr').css({display:'none'});
	}

// 手动选择
	for(var i=0; i<9; i++){
		lis[i].xuhao = i;
		lis[i].onmouseover=function(){
			num = this.xuhao;
			for(var j=0; j<lis.length; j++){
				imgs[j].style.display="none";
				lis[j].style.background='rgba(0,0,0,0.5)';
			}
			imgs[num].style.display='block';
			lis[num].style.background='none';
			bg.style.background=arr[num];
		}
	}
// 手动点击箭头
	$('.ll').click(function(){
		num--;
		num=num<0?8:num;
		$('.lun-tu').eq(num).css({display:'block'}).siblings('.lun-tu').css({display:'none'});
		$('.lun-xia').eq(num).css({background:'none'}).siblings().css({background:'rgba(0,0,0,0.5)'});
		$('#middle-big').css({background:arr[num]});
	})
	$('.lr').click(function(){
		num++;
		num=num>8?0:num;
		$('.lun-tu').eq(num).css({display:'block'}).siblings('.lun_tu').css({display:'none'});
		$('.lun-xia').eq(num).css({background:'none'}).siblings().css({background:'rgba(0,0,0,0.5)'});
		$('#middle-big').css({background:arr[num]});
	})
// 手动点箭头结束

	
/* 	$(".lisnav li").hover(function(){
        $(this).addClass("hover").siblings().removeClass("hover"); 
        var num = $(this).index(); 
        $(".subnav").children(".fullcategory").hide(); 
        $(".subnav").children(".fullcategory").eq(num).show(); 
    })
    $(".lisnav").hover(function(){
        $(".subnav").show(); 
    }, function(){ 
        $(".subnav").hide(); 
        $('li').removeClass("hover"); 
    })

     $(".subnav").children(".item_sub").hover(function(){ 
        var num = $(this).index(); 
        $(".lisnav").children("li").eq(num).addClass("hover"); 
        $(".subnav").show(); 
    }, function(){ 
        $(".subnav").hide(); 
        $(".lisnav").children("li").removeClass("hover"); 
    }) */
 

})